/**
 * 
 */
package Szadoban;


import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

/**
 * Register new players
 */
public class SignUpFrame extends JFrame implements ActionListener {
	JButton okButton;
	JButton cancelButton;
	JLabel nameLabel;
	JTextField nameText;
	JPanel panel;
	
	public SignUpFrame() {
		setTitle("Sign Up");
		setSize(300, 150);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		

		panel = new JPanel();
		panel.setLayout(null);

		nameLabel = new JLabel("ENTER YOUR NAME:");
		nameLabel.setFont(new Font("Arial",Font.BOLD,17));
		nameLabel.setBounds(10, 10, 170, 18);
		nameText = new JTextField(20);
		nameText.setBounds(10, 35, 250, 25);
		okButton = new JButton("OK");
		okButton.setBounds(35, 70, 90, 30);
		cancelButton = new JButton("CANCEL");
		cancelButton.setBounds(140, 70, 90, 30);
		
		
		this.add(panel);
		panel.add(nameLabel);
		panel.add(nameText);
		panel.add(okButton);
		panel.add(cancelButton);
		
		this.setVisible(true);
		
		okButton.addActionListener(this);
		cancelButton.addActionListener(this);
	}



	public void actionPerformed(ActionEvent e) {
		Object source=e.getSource();
		
		if(source==okButton)
		{
			String name=nameText.getText();
	
		Menu.UserList.add(new Users(name,0));
			this.dispose();			
		}
		if(source==cancelButton)
		{
			this.dispose();	
			Menu logmenu = new Menu();
			logmenu.remove(logmenu.c1);
			logmenu.setContentPane(logmenu.c2);
			logmenu.validate();
			logmenu.repaint();	}
	
		
		
	}
	
	public static void main(String[] args) {

		SignUpFrame sign=new SignUpFrame();
	}
	
	
}
